//
//  Team.m
//
//  Created by Kevin Schewior on 04.12.11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "LocationMessage.h"


@implementation LocationMessage

@synthesize username = _username;
@synthesize latitude = _latitude;
@synthesize longitude = _longitude;

-(id)initWithPlayer:(NSString *)username latitude:(double)lat longitude:(double)lng {
	self = [super init];
	if(self){
		_username = username;
        _latitude = lat;
        _longitude = lng;
        
        // Set type of message
        messageType = kLocationMessage;
	}
	return self;
}

-(id)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        _username = [[aDecoder decodeObjectForKey:@"username"] retain];
        _latitude = [aDecoder decodeDoubleForKey:@"latitude"];
        _longitude = [aDecoder decodeDoubleForKey:@"longitude"];
    
    }
    
    return self;
}

-(void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:_username forKey:@"username"];
    [aCoder encodeDouble:_latitude forKey:@"latitude"];
    [aCoder encodeDouble:_longitude forKey:@"longitude"];
}

-(void)dealloc{
	[super dealloc];
	[_username release]; _username = nil;
	_latitude = 0;
    _longitude = 0;
}

@end
